﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace StreamReaderTxtFile
{
    class Program
    {
       
        static void Main(string[] args)
        {
            int counter = 0;
            string line;
            List<string> mylist = new List<string>();
            System.IO.StreamReader file =
             new System.IO.StreamReader(@"c:\test\KCLEFTLT.txt");

            while (!file.EndOfStream)
            {
                line = file.ReadLine().Trim();
                if (!string.IsNullOrEmpty(line))
                {
                    mylist.Add(line.Trim());
                    Console.WriteLine(line);
                    counter++; 
                }
                
            }

            mylist.Sort();
          
            foreach (string s in mylist)
            {
                if (s.Substring(0, 3).ToString().ToUpper() == "FOR" || s.Substring(0, 3).ToString().ToUpper() == "JOB" || s.Substring(0, 3).ToString().ToUpper() == "PGM" || s.Substring(0, 3).ToString().ToUpper() == "AGY")
                    mylist.Skip(1);
                else
                    System.Console.WriteLine(s);
            }
            System.Console.WriteLine("There were {0} lines.", counter);
            System.Console.ReadLine();
        }


        //static void Main(string[] args)
        //{
        //     SkippableStreamReader exampleReader = new SkippableStreamReader(@"c:\test\test.txt");
        //    int counter = 0;
        //    string line;
        //    List<string> mylist = new List<string>();
        //   //exampleReader.SkipLines(2);
        //    // Read the file and display it line by line.
        //    //System.IO.StreamReader file =
        //    //    new System.IO.StreamReader(@"c:\test\test.txt");

        //    while ((line = exampleReader.ReadLine()) != null)
        //    {
        //        //using (StreamWriter writer = new StreamWriter(@"c:\test\outExcel.xls", true))
        //        //{
        //        //    writer.WriteLine(line);
        //        //   // writer.WriteLine(line.Replace(",", ";"));
        //        //}
        //        mylist.Add(line);
        //       // System.Console.WriteLine(line);
        //        counter++;
        //    }

        //    exampleReader.Close();
            
        //    System.Console.WriteLine("There were {0} lines.", counter);
        //    mylist.Sort();
        //    foreach (string s in mylist)
        //    {

        //        if (s.Substring(0, 2).ToString() == "no")
        //           // mylist.Skip(1);
        //            System.Console.ReadLine();
        //        else
        //            System.Console.WriteLine(s);
        //    }
        //    // Suspend the screen.
        //    System.Console.ReadLine();
        //}
    }
    //class SkippableStreamReader : StreamReader
    //{
    //    public SkippableStreamReader(string path) : base(path) { }

    //    public void SkipLines(int linecount)
    //    {
    //        for (int i = 0; i < linecount; i++)
    //        {
    //            this.ReadLine();
    //        }
    //    }
    //}
}
